/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fh.view.running;

import fh.controller.RunTourneyController;
import fh.model.Event;
import fh.view.*;

/**
 *
 * @author Dikkehein
 */
public class RunTourney extends javax.swing.JFrame {

    Event anEvent;
    RunTourneyController rtc;

    /**
     * Creates new form RunTourney
     */
    public RunTourney() {
        initComponents();
    }

    public RunTourney(Event e) {
        initComponents();

        rtc = new RunTourneyController(e);
        updateFields();
    }

    private void updateFields() {
        NameTourneyField.setText(rtc.runningEvent.getName());
        RoundTourneyField.setText(rtc.currentRoundNumber + "");
        TableTourneyField.setText(rtc.tables + "");
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        RoundTourneyField = new javax.swing.JTextField();
        TableTourneyField = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        NameTourneyField = new javax.swing.JTextField();
        btnCreateStart = new javax.swing.JButton();
        btnTableWinners = new javax.swing.JButton();
        LocationEventMainButton2 = new javax.swing.JButton();
        PlayerOverviewButton = new javax.swing.JButton();
        CurrentTourneyButton = new javax.swing.JButton();
        btnNextRound = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setMinimumSize(new java.awt.Dimension(800, 600));

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 30)); // NOI18N
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("Full House");
        jLabel1.setToolTipText("");

        jLabel2.setText("Aantal tafels:");

        jLabel3.setText("Naam:");

        RoundTourneyField.setEditable(false);
        RoundTourneyField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RoundTourneyFieldActionPerformed(evt);
            }
        });

        TableTourneyField.setEditable(false);
        TableTourneyField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TableTourneyFieldActionPerformed(evt);
            }
        });

        jLabel4.setText("Ronde:");

        NameTourneyField.setEditable(false);
        NameTourneyField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                NameTourneyFieldActionPerformed(evt);
            }
        });

        btnCreateStart.setText("Start toernooi");
        btnCreateStart.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCreateStartActionPerformed(evt);
            }
        });

        btnTableWinners.setText("Tafel winnaars");
        btnTableWinners.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTableWinnersActionPerformed(evt);
            }
        });

        LocationEventMainButton2.setText("Locatie & Event");
        LocationEventMainButton2.setMaximumSize(new java.awt.Dimension(111, 23));
        LocationEventMainButton2.setMinimumSize(new java.awt.Dimension(111, 23));
        LocationEventMainButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                LocationEventMainButton2ActionPerformed(evt);
            }
        });

        PlayerOverviewButton.setText("Speler beheer");
        PlayerOverviewButton.setMaximumSize(new java.awt.Dimension(111, 23));
        PlayerOverviewButton.setMinimumSize(new java.awt.Dimension(111, 23));
        PlayerOverviewButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                PlayerOverviewButtonActionPerformed(evt);
            }
        });

        CurrentTourneyButton.setText("Toernooi runnen");
        CurrentTourneyButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CurrentTourneyButtonActionPerformed(evt);
            }
        });

        btnNextRound.setText("Volgende ronde");
        btnNextRound.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNextRoundActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 800, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel4)
                            .addComponent(jLabel3)
                            .addComponent(jLabel2))
                        .addGap(28, 28, 28)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(NameTourneyField, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(RoundTourneyField, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(TableTourneyField, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(373, 373, 373)
                                .addComponent(btnCreateStart, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btnNextRound, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addGap(107, 107, 107)
                                .addComponent(btnTableWinners, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(55, 55, 55)
                        .addComponent(LocationEventMainButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 216, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(PlayerOverviewButton, javax.swing.GroupLayout.PREFERRED_SIZE, 216, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(CurrentTourneyButton, javax.swing.GroupLayout.PREFERRED_SIZE, 216, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(CurrentTourneyButton, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(PlayerOverviewButton, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(LocationEventMainButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(77, 77, 77)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(NameTourneyField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnCreateStart, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(RoundTourneyField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(TableTourneyField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(btnTableWinners, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnNextRound, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(148, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void RoundTourneyFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RoundTourneyFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_RoundTourneyFieldActionPerformed

    private void TableTourneyFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TableTourneyFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_TableTourneyFieldActionPerformed

    private void NameTourneyFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NameTourneyFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_NameTourneyFieldActionPerformed

    private void btnCreateStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCreateStartActionPerformed
        rtc.startTourney();
        updateFields();
    }//GEN-LAST:event_btnCreateStartActionPerformed

    private void btnTableWinnersActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTableWinnersActionPerformed
        new TableWinners(rtc.runningEvent, rtc.currentRoundNumber).setVisible(true);
        this.dispose();
    }//GEN-LAST:event_btnTableWinnersActionPerformed

    private void LocationEventMainButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LocationEventMainButton2ActionPerformed
        new LocationEventOverview().setVisible(true);
        this.dispose();
    }//GEN-LAST:event_LocationEventMainButton2ActionPerformed

    private void PlayerOverviewButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PlayerOverviewButtonActionPerformed
        new PlayerOverview().setVisible(true);
        this.dispose();
    }//GEN-LAST:event_PlayerOverviewButtonActionPerformed

    private void CurrentTourneyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CurrentTourneyButtonActionPerformed
        new CurrentTourneyOverview().setVisible(true);
        this.dispose();
    }//GEN-LAST:event_CurrentTourneyButtonActionPerformed

    private void btnNextRoundActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNextRoundActionPerformed
        rtc.startNextRound();
        updateFields();
    }//GEN-LAST:event_btnNextRoundActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(RunTourney.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(RunTourney.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(RunTourney.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(RunTourney.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new RunTourney().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton CurrentTourneyButton;
    private javax.swing.JButton LocationEventMainButton2;
    private javax.swing.JTextField NameTourneyField;
    private javax.swing.JButton PlayerOverviewButton;
    private javax.swing.JTextField RoundTourneyField;
    private javax.swing.JTextField TableTourneyField;
    private javax.swing.JButton btnCreateStart;
    private javax.swing.JButton btnNextRound;
    private javax.swing.JButton btnTableWinners;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    // End of variables declaration//GEN-END:variables
}
